package com.ff.discounts.repository

import com.ff.discounts.api.DefaultNetworkService
import com.ff.discounts.boxindexdata.BoxList
import com.ff.discounts.component.address.AddressData
import com.ff.discounts.component.address.AreaData
import com.ff.discounts.component.address.NewAreaData
import com.ff.discounts.component.login.LoginRequest
import com.ff.discounts.component.login.TokenData
import com.ff.discounts.entity.response.DetailResponse
import com.ff.discounts.entity.response.ListResponse
import com.ff.discounts.entity.response.OriginalResponse

/**
 *数据仓库
 * @author: fufang
 * @date: 2023/10/23
 */
object DefaultNetworkRepository {
    private val service: DefaultNetworkService by lazy {
        DefaultNetworkService.create()
    }

    suspend fun getAllList(): ListResponse<BoxList> {
        return service.getAllList()
    }
    suspend fun codeLogin(data: LoginRequest): OriginalResponse<Any> {
        return service.codeLogin(data)
    }
     //密码登录
     suspend fun passwordLogin(data: LoginRequest): DetailResponse<TokenData> {
         return service.passwordLogin(data)
     }
    /// 获取验证码
    suspend fun getCode(data: LoginRequest): OriginalResponse<Any> {
        return service.getCode(data)
    }

    //获取当前用户地址
    suspend fun getAddressList():ListResponse<AddressData>{
        return service.getAddressList()
    }
    // 添加用户地址
    suspend fun addAddress(data: AddressData):DetailResponse<AddressData>{
        return service.addAddress(data)
    }
    // 获取省市区三级列表
    suspend fun getArea():DetailResponse<NewAreaData>{
        return service.getArea()
    }

}